
'===============================================================================
'  Generated From - VbNet_SQL_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  **
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'MustInherit' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can Override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  Public Class YourObject
'    Inherits _YourObject
'
'  End Class
'
'===============================================================================

' Generated by MyGeneration Version # (1.3.0.3)

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Collections.Specialized

Imports MyGeneration.dOOdads

NameSpace Class_RC

Public MustInherit Class _CLIENTES
	Inherits SqlClientEntity

		Public Sub New() 
			Me.QuerySource = "CLIENTES"
			Me.MappingName = "CLIENTES"
		End Sub

	'=================================================================
	'  Public Overrides Sub AddNew()
	'=================================================================
	'
	'=================================================================
	Public Overrides Sub AddNew()
		MyBase.AddNew()
				
	End Sub
	
	Public Overrides Sub FlushData()
		Me._whereClause = nothing
		Me._aggregateClause = nothing		
		MyBase.FlushData()
	End Sub
	
		
	'=================================================================
	'  	Public Function LoadAll() As Boolean
	'=================================================================
	'  Loads all of the records in the database, and sets the currentRow to the first row
	'=================================================================
	Public Function LoadAll() As Boolean
	
		Dim parameters As ListDictionary = Nothing
		
		
    	Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_CLIENTESLoadAll]", parameters)
		
	End Function

	'=================================================================
	' Public Overridable Function LoadByPrimaryKey()  As Boolean
	'=================================================================
	'  Loads a single row of via the primary key
	'=================================================================
        Public Overridable Function LoadByPrimaryKey(ByVal CodCliente As Integer) As Boolean

            Dim parameters As ListDictionary = New ListDictionary()
            parameters.Add(_CLIENTES.Parameters.CodCliente, CodCliente)


            Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_CLIENTESLoadByPrimaryKey]", parameters)

        End Function

#Region "Parameters"
        Protected Class Parameters

            Public Shared ReadOnly Property CodCliente As SqlParameter
                Get
                    Return New SqlParameter("@CodCliente", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property Nombre As SqlParameter
                Get
                    Return New SqlParameter("@Nombre", SqlDbType.NVarChar, 100)
                End Get
            End Property

            Public Shared ReadOnly Property Direccion As SqlParameter
                Get
                    Return New SqlParameter("@Direccion", SqlDbType.NVarChar, 250)
                End Get
            End Property

            Public Shared ReadOnly Property Telefono As SqlParameter
                Get
                    Return New SqlParameter("@Telefono", SqlDbType.NVarChar, 20)
                End Get
            End Property

            Public Shared ReadOnly Property Celular As SqlParameter
                Get
                    Return New SqlParameter("@Celular", SqlDbType.NVarChar, 20)
                End Get
            End Property

            Public Shared ReadOnly Property CodCiudad As SqlParameter
                Get
                    Return New SqlParameter("@CodCiudad", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property Ruc As SqlParameter
                Get
                    Return New SqlParameter("@Ruc", SqlDbType.VarChar, 15)
                End Get
            End Property

            Public Shared ReadOnly Property Saldo As SqlParameter
                Get
                    Return New SqlParameter("@Saldo", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodTipoCliente As SqlParameter
                Get
                    Return New SqlParameter("@CodTipoCliente", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodUsuario As SqlParameter
                Get
                    Return New SqlParameter("@CodUsuario", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property FechaActualizacion As SqlParameter
                Get
                    Return New SqlParameter("@FechaActualizacion", SqlDbType.DateTime, 0)
                End Get
            End Property

        End Class
#End Region

#Region "ColumnNames"
        Public Class ColumnNames

            Public Const CodCliente As String = "codCliente"
            Public Const Nombre As String = "nombre"
            Public Const Direccion As String = "direccion"
            Public Const Telefono As String = "telefono"
            Public Const Celular As String = "celular"
            Public Const CodCiudad As String = "codCiudad"
            Public Const Ruc As String = "ruc"
            Public Const Saldo As String = "saldo"
            Public Const CodTipoCliente As String = "codTipoCliente"
            Public Const CodUsuario As String = "codUsuario"
            Public Const FechaActualizacion As String = "fechaActualizacion"

            Public Shared Function ToPropertyName(ByVal columnName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(CodCliente) = _CLIENTES.PropertyNames.CodCliente
                    ht(Nombre) = _CLIENTES.PropertyNames.Nombre
                    ht(Direccion) = _CLIENTES.PropertyNames.Direccion
                    ht(Telefono) = _CLIENTES.PropertyNames.Telefono
                    ht(Celular) = _CLIENTES.PropertyNames.Celular
                    ht(CodCiudad) = _CLIENTES.PropertyNames.CodCiudad
                    ht(Ruc) = _CLIENTES.PropertyNames.Ruc
                    ht(Saldo) = _CLIENTES.PropertyNames.Saldo
                    ht(CodTipoCliente) = _CLIENTES.PropertyNames.CodTipoCliente
                    ht(CodUsuario) = _CLIENTES.PropertyNames.CodUsuario
                    ht(FechaActualizacion) = _CLIENTES.PropertyNames.FechaActualizacion

                End If

                Return CType(ht(columnName), String)

            End Function

            Private Shared ht As Hashtable = Nothing
        End Class
#End Region

#Region "PropertyNames"
        Public Class PropertyNames

            Public Const CodCliente As String = "CodCliente"
            Public Const Nombre As String = "Nombre"
            Public Const Direccion As String = "Direccion"
            Public Const Telefono As String = "Telefono"
            Public Const Celular As String = "Celular"
            Public Const CodCiudad As String = "CodCiudad"
            Public Const Ruc As String = "Ruc"
            Public Const Saldo As String = "Saldo"
            Public Const CodTipoCliente As String = "CodTipoCliente"
            Public Const CodUsuario As String = "CodUsuario"
            Public Const FechaActualizacion As String = "FechaActualizacion"

            Public Shared Function ToColumnName(ByVal propertyName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(CodCliente) = _CLIENTES.ColumnNames.CodCliente
                    ht(Nombre) = _CLIENTES.ColumnNames.Nombre
                    ht(Direccion) = _CLIENTES.ColumnNames.Direccion
                    ht(Telefono) = _CLIENTES.ColumnNames.Telefono
                    ht(Celular) = _CLIENTES.ColumnNames.Celular
                    ht(CodCiudad) = _CLIENTES.ColumnNames.CodCiudad
                    ht(Ruc) = _CLIENTES.ColumnNames.Ruc
                    ht(Saldo) = _CLIENTES.ColumnNames.Saldo
                    ht(CodTipoCliente) = _CLIENTES.ColumnNames.CodTipoCliente
                    ht(CodUsuario) = _CLIENTES.ColumnNames.CodUsuario
                    ht(FechaActualizacion) = _CLIENTES.ColumnNames.FechaActualizacion

                End If

                Return CType(ht(propertyName), String)

            End Function

            Private Shared ht As Hashtable = Nothing

        End Class
#End Region

#Region "StringPropertyNames"
        Public Class StringPropertyNames

            Public Const CodCliente As String = "s_CodCliente"
            Public Const Nombre As String = "s_Nombre"
            Public Const Direccion As String = "s_Direccion"
            Public Const Telefono As String = "s_Telefono"
            Public Const Celular As String = "s_Celular"
            Public Const CodCiudad As String = "s_CodCiudad"
            Public Const Ruc As String = "s_Ruc"
            Public Const Saldo As String = "s_Saldo"
            Public Const CodTipoCliente As String = "s_CodTipoCliente"
            Public Const CodUsuario As String = "s_CodUsuario"
            Public Const FechaActualizacion As String = "s_FechaActualizacion"

        End Class
#End Region

#Region "Properties"
        Public Overridable Property CodCliente As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodCliente)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodCliente, Value)
            End Set
        End Property

        Public Overridable Property Nombre As String
            Get
                Return MyBase.Getstring(ColumnNames.Nombre)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.Nombre, Value)
            End Set
        End Property

        Public Overridable Property Direccion As String
            Get
                Return MyBase.Getstring(ColumnNames.Direccion)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.Direccion, Value)
            End Set
        End Property

        Public Overridable Property Telefono As String
            Get
                Return MyBase.Getstring(ColumnNames.Telefono)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.Telefono, Value)
            End Set
        End Property

        Public Overridable Property Celular As String
            Get
                Return MyBase.Getstring(ColumnNames.Celular)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.Celular, Value)
            End Set
        End Property

        Public Overridable Property CodCiudad As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodCiudad)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodCiudad, Value)
            End Set
        End Property

        Public Overridable Property Ruc As String
            Get
                Return MyBase.Getstring(ColumnNames.Ruc)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.Ruc, Value)
            End Set
        End Property

        Public Overridable Property Saldo As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.Saldo)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.Saldo, Value)
            End Set
        End Property

        Public Overridable Property CodTipoCliente As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodTipoCliente)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodTipoCliente, Value)
            End Set
        End Property

        Public Overridable Property CodUsuario As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodUsuario)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodUsuario, Value)
            End Set
        End Property

        Public Overridable Property FechaActualizacion As DateTime
            Get
                Return MyBase.GetDateTime(ColumnNames.FechaActualizacion)
            End Get
            Set(ByVal Value As DateTime)
                MyBase.SetDateTime(ColumnNames.FechaActualizacion, Value)
            End Set
        End Property


#End Region
	
	#Region "String Properties" 

		Public Overridable Property s_CodCliente As String
			Get
				If Me.IsColumnNull(ColumnNames.CodCliente) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodCliente)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodCliente)
				Else
					Me.CodCliente = MyBase.SetintAsString(ColumnNames.CodCliente, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Nombre As String
			Get
				If Me.IsColumnNull(ColumnNames.Nombre) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.Nombre)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Nombre)
				Else
					Me.Nombre = MyBase.SetstringAsString(ColumnNames.Nombre, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Direccion As String
			Get
				If Me.IsColumnNull(ColumnNames.Direccion) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.Direccion)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Direccion)
				Else
					Me.Direccion = MyBase.SetstringAsString(ColumnNames.Direccion, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Telefono As String
			Get
				If Me.IsColumnNull(ColumnNames.Telefono) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.Telefono)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Telefono)
				Else
					Me.Telefono = MyBase.SetstringAsString(ColumnNames.Telefono, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Celular As String
			Get
				If Me.IsColumnNull(ColumnNames.Celular) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.Celular)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Celular)
				Else
					Me.Celular = MyBase.SetstringAsString(ColumnNames.Celular, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodCiudad As String
			Get
				If Me.IsColumnNull(ColumnNames.CodCiudad) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodCiudad)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodCiudad)
				Else
					Me.CodCiudad = MyBase.SetintAsString(ColumnNames.CodCiudad, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Ruc As String
			Get
				If Me.IsColumnNull(ColumnNames.Ruc) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.Ruc)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Ruc)
				Else
					Me.Ruc = MyBase.SetstringAsString(ColumnNames.Ruc, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Saldo As String
			Get
				If Me.IsColumnNull(ColumnNames.Saldo) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.Saldo)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Saldo)
				Else
					Me.Saldo = MyBase.SetdecimalAsString(ColumnNames.Saldo, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodTipoCliente As String
			Get
				If Me.IsColumnNull(ColumnNames.CodTipoCliente) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodTipoCliente)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodTipoCliente)
				Else
					Me.CodTipoCliente = MyBase.SetintAsString(ColumnNames.CodTipoCliente, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodUsuario As String
			Get
				If Me.IsColumnNull(ColumnNames.CodUsuario) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodUsuario)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodUsuario)
				Else
					Me.CodUsuario = MyBase.SetintAsString(ColumnNames.CodUsuario, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_FechaActualizacion As String
			Get
				If Me.IsColumnNull(ColumnNames.FechaActualizacion) Then
					Return String.Empty
				Else
					Return MyBase.GetDateTimeAsString(ColumnNames.FechaActualizacion)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.FechaActualizacion)
				Else
					Me.FechaActualizacion = MyBase.SetDateTimeAsString(ColumnNames.FechaActualizacion, Value)
				End If
			End Set
		End Property


	#End Region  	

	#Region "Where Clause"
    Public Class WhereClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffWhereParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffWhereParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "TearOff's"
		Public class TearOffWhereParameter

			Public Sub New(ByVal clause As WhereClause)
				Me._clause = clause
			End Sub
		
	
			Public ReadOnly Property CodCliente() As WhereParameter
				Get
					Dim where As WhereParameter = New WhereParameter(ColumnNames.CodCliente, Parameters.CodCliente)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Nombre() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Nombre, Parameters.Nombre)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Direccion() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Direccion, Parameters.Direccion)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Telefono() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Telefono, Parameters.Telefono)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Celular() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Celular, Parameters.Celular)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodCiudad() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodCiudad, Parameters.CodCiudad)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Ruc() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Ruc, Parameters.Ruc)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Saldo() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Saldo, Parameters.Saldo)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodTipoCliente() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodTipoCliente, Parameters.CodTipoCliente)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodUsuario() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property FechaActualizacion() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property


			Private _clause as WhereClause
		End Class
		#End Region	

		Public ReadOnly Property CodCliente() As WhereParameter 
			Get
				If _CodCliente_W Is Nothing Then
					_CodCliente_W = TearOff.CodCliente
				End If
				Return _CodCliente_W
			End Get
		End Property

		Public ReadOnly Property Nombre() As WhereParameter 
			Get
				If _Nombre_W Is Nothing Then
					_Nombre_W = TearOff.Nombre
				End If
				Return _Nombre_W
			End Get
		End Property

		Public ReadOnly Property Direccion() As WhereParameter 
			Get
				If _Direccion_W Is Nothing Then
					_Direccion_W = TearOff.Direccion
				End If
				Return _Direccion_W
			End Get
		End Property

		Public ReadOnly Property Telefono() As WhereParameter 
			Get
				If _Telefono_W Is Nothing Then
					_Telefono_W = TearOff.Telefono
				End If
				Return _Telefono_W
			End Get
		End Property

		Public ReadOnly Property Celular() As WhereParameter 
			Get
				If _Celular_W Is Nothing Then
					_Celular_W = TearOff.Celular
				End If
				Return _Celular_W
			End Get
		End Property

		Public ReadOnly Property CodCiudad() As WhereParameter 
			Get
				If _CodCiudad_W Is Nothing Then
					_CodCiudad_W = TearOff.CodCiudad
				End If
				Return _CodCiudad_W
			End Get
		End Property

		Public ReadOnly Property Ruc() As WhereParameter 
			Get
				If _Ruc_W Is Nothing Then
					_Ruc_W = TearOff.Ruc
				End If
				Return _Ruc_W
			End Get
		End Property

		Public ReadOnly Property Saldo() As WhereParameter 
			Get
				If _Saldo_W Is Nothing Then
					_Saldo_W = TearOff.Saldo
				End If
				Return _Saldo_W
			End Get
		End Property

		Public ReadOnly Property CodTipoCliente() As WhereParameter 
			Get
				If _CodTipoCliente_W Is Nothing Then
					_CodTipoCliente_W = TearOff.CodTipoCliente
				End If
				Return _CodTipoCliente_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As WhereParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As WhereParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Private _CodCliente_W As WhereParameter = Nothing
		Private _Nombre_W As WhereParameter = Nothing
		Private _Direccion_W As WhereParameter = Nothing
		Private _Telefono_W As WhereParameter = Nothing
		Private _Celular_W As WhereParameter = Nothing
		Private _CodCiudad_W As WhereParameter = Nothing
		Private _Ruc_W As WhereParameter = Nothing
		Private _Saldo_W As WhereParameter = Nothing
		Private _CodTipoCliente_W As WhereParameter = Nothing
		Private _CodUsuario_W As WhereParameter = Nothing
		Private _FechaActualizacion_W As WhereParameter = Nothing

			Public Sub WhereClauseReset()

			_CodCliente_W = Nothing
			_Nombre_W = Nothing
			_Direccion_W = Nothing
			_Telefono_W = Nothing
			_Celular_W = Nothing
			_CodCiudad_W = Nothing
			_Ruc_W = Nothing
			_Saldo_W = Nothing
			_CodTipoCliente_W = Nothing
			_CodUsuario_W = Nothing
			_FechaActualizacion_W = Nothing
				Me._entity.Query.FlushWhereParameters()

			End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffWhereParameter
    End Class	

	Public ReadOnly Property Where() As WhereClause
		Get
			If _whereClause Is Nothing Then
				_whereClause = New WhereClause(Me)
			End If
	
			Return _whereClause
		End Get
	End Property
	
	Private _whereClause As WhereClause = Nothing	
#End Region	

#Region "Aggregate Clause"
    Public Class AggregateClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffAggregateParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffAggregateParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "AggregateParameter TearOff's"
		Public class TearOffAggregateParameter

			Public Sub New(ByVal clause As AggregateClause)
				Me._clause = clause
			End Sub
		
	
		Public ReadOnly Property CodCliente() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodCliente, Parameters.CodCliente)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Nombre() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Nombre, Parameters.Nombre)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Direccion() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Direccion, Parameters.Direccion)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Telefono() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Telefono, Parameters.Telefono)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Celular() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Celular, Parameters.Celular)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodCiudad() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodCiudad, Parameters.CodCiudad)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Ruc() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Ruc, Parameters.Ruc)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Saldo() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Saldo, Parameters.Saldo)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodTipoCliente() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodTipoCliente, Parameters.CodTipoCliente)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property


			Private _clause as AggregateClause
		End Class
		#End Region	

		Public ReadOnly Property CodCliente() As AggregateParameter 
			Get
				If _CodCliente_W Is Nothing Then
					_CodCliente_W = TearOff.CodCliente
				End If
				Return _CodCliente_W
			End Get
		End Property

		Public ReadOnly Property Nombre() As AggregateParameter 
			Get
				If _Nombre_W Is Nothing Then
					_Nombre_W = TearOff.Nombre
				End If
				Return _Nombre_W
			End Get
		End Property

		Public ReadOnly Property Direccion() As AggregateParameter 
			Get
				If _Direccion_W Is Nothing Then
					_Direccion_W = TearOff.Direccion
				End If
				Return _Direccion_W
			End Get
		End Property

		Public ReadOnly Property Telefono() As AggregateParameter 
			Get
				If _Telefono_W Is Nothing Then
					_Telefono_W = TearOff.Telefono
				End If
				Return _Telefono_W
			End Get
		End Property

		Public ReadOnly Property Celular() As AggregateParameter 
			Get
				If _Celular_W Is Nothing Then
					_Celular_W = TearOff.Celular
				End If
				Return _Celular_W
			End Get
		End Property

		Public ReadOnly Property CodCiudad() As AggregateParameter 
			Get
				If _CodCiudad_W Is Nothing Then
					_CodCiudad_W = TearOff.CodCiudad
				End If
				Return _CodCiudad_W
			End Get
		End Property

		Public ReadOnly Property Ruc() As AggregateParameter 
			Get
				If _Ruc_W Is Nothing Then
					_Ruc_W = TearOff.Ruc
				End If
				Return _Ruc_W
			End Get
		End Property

		Public ReadOnly Property Saldo() As AggregateParameter 
			Get
				If _Saldo_W Is Nothing Then
					_Saldo_W = TearOff.Saldo
				End If
				Return _Saldo_W
			End Get
		End Property

		Public ReadOnly Property CodTipoCliente() As AggregateParameter 
			Get
				If _CodTipoCliente_W Is Nothing Then
					_CodTipoCliente_W = TearOff.CodTipoCliente
				End If
				Return _CodTipoCliente_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Private _CodCliente_W As AggregateParameter = Nothing
		Private _Nombre_W As AggregateParameter = Nothing
		Private _Direccion_W As AggregateParameter = Nothing
		Private _Telefono_W As AggregateParameter = Nothing
		Private _Celular_W As AggregateParameter = Nothing
		Private _CodCiudad_W As AggregateParameter = Nothing
		Private _Ruc_W As AggregateParameter = Nothing
		Private _Saldo_W As AggregateParameter = Nothing
		Private _CodTipoCliente_W As AggregateParameter = Nothing
		Private _CodUsuario_W As AggregateParameter = Nothing
		Private _FechaActualizacion_W As AggregateParameter = Nothing

		Public Sub AggregateClauseReset()

		_CodCliente_W = Nothing
		_Nombre_W = Nothing
		_Direccion_W = Nothing
		_Telefono_W = Nothing
		_Celular_W = Nothing
		_CodCiudad_W = Nothing
		_Ruc_W = Nothing
		_Saldo_W = Nothing
		_CodTipoCliente_W = Nothing
		_CodUsuario_W = Nothing
		_FechaActualizacion_W = Nothing
			Me._entity.Query.FlushAggregateParameters()

		End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffAggregateParameter
    End Class	

	Public ReadOnly Property Aggregate() As AggregateClause
		Get
			If _aggregateClause Is Nothing Then
				_aggregateClause = New AggregateClause(Me)
			End If
	
			Return _aggregateClause
		End Get
	End Property
	
	Private _aggregateClause As AggregateClause = Nothing	
#End Region	

	Protected Overrides Function GetInsertCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_CLIENTESInsert]" 
	    
		CreateParameters(cmd)
		
		Dim p As SqlParameter
		p = cmd.Parameters(Parameters.CodCliente.ParameterName)
		p.Direction = ParameterDirection.Output
    
		Return cmd 

  	End Function
	
	Protected Overrides Function GetUpdateCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_CLIENTESUpdate]" 
		
		CreateParameters(cmd) 
		    
		Return cmd
	
	End Function	
	
	Protected Overrides Function GetDeleteCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_CLIENTESDelete]" 
		
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodCliente)
		p.SourceColumn = ColumnNames.CodCliente
		p.SourceVersion = DataRowVersion.Current

  
		Return cmd
	
	End Function	
	
	Private Sub CreateParameters(ByVal cmd As SqlCommand)
	
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodCliente)
		p.SourceColumn = ColumnNames.CodCliente
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Nombre)
		p.SourceColumn = ColumnNames.Nombre
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Direccion)
		p.SourceColumn = ColumnNames.Direccion
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Telefono)
		p.SourceColumn = ColumnNames.Telefono
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Celular)
		p.SourceColumn = ColumnNames.Celular
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodCiudad)
		p.SourceColumn = ColumnNames.CodCiudad
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Ruc)
		p.SourceColumn = ColumnNames.Ruc
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Saldo)
		p.SourceColumn = ColumnNames.Saldo
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodTipoCliente)
		p.SourceColumn = ColumnNames.CodTipoCliente
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodUsuario)
		p.SourceColumn = ColumnNames.CodUsuario
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.FechaActualizacion)
		p.SourceColumn = ColumnNames.FechaActualizacion
		p.SourceVersion = DataRowVersion.Current


	End Sub	

End Class

End NameSpace

